package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.Salary;
import cn.wolfcode.car.mapper.SalaryMapper;
import cn.wolfcode.car.qo.SalaryDetailQueryObject;
import cn.wolfcode.car.qo.SalaryQueryObject;
import cn.wolfcode.car.service.ISalaryService;
import cn.wolfcode.car.vo.BusinessReportVO;
import cn.wolfcode.car.vo.SalaryReprotVo;
import cn.wolfcode.car.vo.SalaryVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SalaryServiceImpl implements ISalaryService {

    @Autowired
    private SalaryMapper salaryMapper;

    @Override
    public int delete(Long id) {
        return salaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int save(Salary record) {
        return salaryMapper.insert(record);
    }

    @Override
    public Salary get(Long id) {
        return salaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Salary> list(SalaryQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Salary> list = salaryMapper.selectForPage(qo);
        return new PageInfo<>(list);
    }

    @Override
    public List<Salary> listAll() {
        return salaryMapper.selectAll();
    }

    @Override
    public int update(Salary record) {
        return salaryMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<SalaryReprotVo> selectByGroup(SalaryDetailQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<SalaryReprotVo> list = salaryMapper.selectByGroup(qo);
        return new PageInfo<>(list);
    }

    @Override
    public List<SalaryReprotVo> selectByGroupNotLimit(SalaryDetailQueryObject qo) {
        return salaryMapper.selectByGroup(qo);
    }


}
